package com.my.encoder;

import com.my.util.Tags;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;

import java.nio.charset.Charset;

/**
 * @Author hujf
 * @Date 2021/10/25 11:21
 * @Description TODO
 */
public class WordSplitter extends OneToOneDecoder {


    private static final Charset CHARSET = Charset.forName("ISO-8859-1");

    /** Constructor. */
    public WordSplitter() {
    }
    @Override
    protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
        return Tags.splitString(((ChannelBuffer) msg).toString(CHARSET), ' ');
    }
}
